<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>编辑页面</title>
</head>
<body>

<div align="center">
    <input type="text" id="id" style="display: none" th:value="${userInfo.id}"><br>
    名称：<input type="text" id="userName" th:value="${userInfo.userName}"><br>
    电话：<input type="text" id="phone" th:value="${userInfo.phone}"><br>
    身份证号码：<input type="text" id="idCard" th:value="${userInfo.idCard}"><br>
    省份：<input type="text" id="province" th:value="${userInfo.province}"><br>
    城市：<input type="text" id="city" th:value="${userInfo.city}"><br>
    邮箱：<input type="text" id="email" th:value="${userInfo.email}"><br>
    备注：<input type="text" id="remark" th:value="${userInfo.remark}"><br>
    <button type="button" onclick="submit()">提交信息</button>
</div>
<a href="/toMain" th:href="@{/toMain}">返回主页</a>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
    function submit() {
        var userName=$("#userName").val()
        var phone=$("#phone").val()
        var idCard=$("#idCard").val()
        var province=$("#province").val()
        var city=$("#city").val()
        var email=$("#email").val()
        var remark=$("#remark").val()
        var id=$("#id").val();
        if (id==null||""==id.trim()){
            id=0;
        }
        $.ajax({
            url:"[[@{/addAndUpdInfo}]]",
            type:"post",
            dataType:"json",
            data:{"id":id,"userName":userName,"phone":phone,"idCard":idCard,"province":province,"city":city,"email":email,"remark":remark},
            success:function (data) {
                if (data.code==1){
                    alert(data.message)
                    location.href="[[@{/toMain}]]"
                }else{
                    alert(data.message)
                }
            }
        })
    }
</script>
</html>